import { Injectable, Logger } from '@nestjs/common';
import { CreateDriverInfoDto } from './dto/create-driver_info.dto';
import { UpdateDriverInfoDto } from './dto/update-driver_info.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { CustomerInfo } from '../../daijia_customer/customer_info/entities/customer_info.entity';
import { Repository } from 'typeorm';
import { DriverInfo } from './entities/driver_info.entity';
import { SuccessResponse } from '../../../util/ResultResponse';

@Injectable()
export class DriverInfoService {
  private readonly logger: Logger = new Logger('DriverInfoService');

  constructor(
    @InjectRepository(DriverInfo)
    private readonly driverInfoRepository: Repository<DriverInfo>,
  ) {}

  create(createDriverInfoDto: CreateDriverInfoDto) {
    return 'This action adds a new driverInfo';
  }

  async findAll() : Promise<SuccessResponse<DriverInfo[]>>  {
    return await this.driverInfoRepository.find().then(result => {
      return {
        code: 0,
        data: result,
        message: '成功',
      };
    })
  }

  findOne(id: number) {
    return `This action returns a #${id} driverInfo`;
  }

  update(id: number, updateDriverInfoDto: UpdateDriverInfoDto) {
    return `This action updates a #${id} driverInfo`;
  }

  remove(id: number) {
    return `This action removes a #${id} driverInfo`;
  }
}
